package Java.A;

public class Triangle implements Ishape {
    Point ptA;
    Point ptB;
    Point ptC;

    public Triangle(Point ptA, Point ptB, Point ptC) {
        this.ptA = ptA;
        this.ptB = ptB;
        this.ptC = ptC;
    }

    public final double getEdgeA() {
        return Math.sqrt(Math.pow(ptA.x - ptB.x, 2) + Math.pow(ptA.y - ptB.y, 2));
    }

    public final double getEdgeB() {
        return Math.sqrt(Math.pow(ptA.x - ptC.x, 2) + Math.pow(ptA.y - ptC.y, 2));
    }

    public final double getEdgeC() {
        return Math.sqrt(Math.pow(ptB.x - ptC.x, 2) + Math.pow(ptB.y - ptC.y, 2));
    }

    @Override
    public double perimeter() {
        return getEdgeA() + getEdgeB() + getEdgeC();
    }

    @Override
    public double area() {
        double p = (getEdgeA() + getEdgeB() + getEdgeC()) / 2;
        return Math.sqrt(p * (p - getEdgeA()) * (p - getEdgeB()) * (p - getEdgeC()));
    }

    @Override
    public void draw() {
        System.out.println("三角形：");
    }

    public static void main(String[] args) {

    }

}
